package com.mysql.study.cotroller.back;


import com.mysql.study.entity.Goods;
import com.mysql.study.service.GoodsService;
import com.mysql.study.utils.UtilsTool;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
@Controller
public class GoodsCotroller {
    @Autowired
    private GoodsService goodsService;
    @Autowired
    private UtilsTool utilsTool;

    /**
     * 获得全部数据方便调用
     */
    List<Goods> FindGoodsAll(){
        return this.goodsService.GoodsAll();
    }

    /**
     * 传参到前端
     * @param id
     * @param model
     * @return
     */
    @RequestMapping("/shop")
    String sthopGoods(int id, Model model){
        Goods goods = this.goodsService.FindKeyIdGoods(id);
        model.addAttribute("goods", goods);
        return "page/front/goods_detail";
    }
}
